﻿using System;
using System.Collections.Generic;

using DigitalQuran.Data.Metadata;

namespace DigitalQuran.Collection
{
    /// <summary>
    /// Collection of <see cref="DigitalQuran.Station"/>
    /// </summary>
    public class StationCollection : ReadOnlyCollection<Station>
    {
        public const int TotalStations = 7;

        internal StationCollection() : base(TotalStations) { }

        public override Station this[int index]
        {
            get { return _Stations[index]; }
        }

        public override IEnumerator<Station> GetEnumerator()
        {
            foreach (var item in _Stations)
            {
                yield return item;
            }
        }

        static Station[] _Stations = new Station[TotalStations];
        internal static void LoadData(IEnumerator<ValueSpan> e)
        {
            for (int i = 0; i < TotalStations; i++)
            {
                e.MoveNext();
                _Stations[i] = new Station(i, e.Current.LowerBound, e.Current.Count);
            }
        }
    }
}